<?php slot('theme','now'); ?>
<div class="W100p mainptn">
	<div class="Cw1280">
        <!--成长烦恼-->
        <div class="Czfn_div" style="width:860px;">
        
        	<style type="text/css">
			table.formtab {float:left; color:#666;}
			table.formtab tr td {font-size:16px; padding-top:30px; }
			table.formtab #cktitle {width:368px; height:28px; line-height:28px; border:1px solid #808080;}
			table.formtab #imgDiv div {width:158px; height:118px; max-height:118px;max-width: 158px;border:1px solid #cccccc; background:#eeece9; float:left; overflow:hidden; margin-right:30px;}
                        table.formtab #imgDiv div img{width:158px; height:118px; max-height:118px;max-width: 158px;}
			table.formtab #imgDiv #imgAdd {background:url('<?php echo image_path('imgAdd.gif'); ?>') no-repeat; border:none; cursor:pointer}
			table.formtab textarea {width:688px; height:283px; border:1px solid #808080;}
			table.formtab input.sub {width:56px; height:28px; border:1px solid #de6b1b; background:#fa7a20; color:#fff; text-align:center; float:left; border-radius:3px;}
			table.formtab input.ret {width:56px; height:28px; border:1px solid #cccccc; background:#808080; color:#fff; text-align:center; float:left; border-radius:3px; margin-left:30px;}
			</style>
            <div class="DecGtitle"><span>发布小组新贴</span></div>
            <form  id="create_theme" action="<?php echo url_for('theme/create'); ?>" method="post" onSubmit="return checkForm();">
            <table cellpadding="0" cellspacing="0" width="100%" class="formtab">
           		<tr><td width="90"><strong>帖子标题：</strong></td><td><input type="text" name="title" id="cktitle"></td></tr>
                <tr><td valign="top"><strong>帖子图片：</strong></td>
                    <td id="imgDiv">
<!--                	<div>img标签区域</div>
                    <div>img标签区域</div>-->
                    <div id="imgAdd"><div id="file_upload"></div></div>
                </td>
                </tr>
                <tr><td valign="top"><strong>帖子正文：</strong></td><td><textarea name="content" id="ckcontent"></textarea></td></tr>
                <tr><td>&nbsp;</td><td><input type="submit" name="submit" value="发表" class="sub"><input type="reset" name="reset" value="取消" class="ret"></td></tr>
            </table>
                <input type="hidden" name="group_id" value="<?php echo $sf_request->getParameter('group_id'); ?>" />
            </form>
            <script>
			function checkForm(){
				cktitle = $('#cktitle').val();
				ckcontent = $('#ckcontent').val();
				if(cktitle.length<=0){
					layer.msg('请输入帖子标题！');
					return false;
				}
				if(ckcontent.length<=0){
					layer.msg('请输入帖子正文！');
					return false;
				}
				return true;
			}
			</script>
            
        </div>
        
        <!--右边-->
        <div class="DeRight" style="width:360px;">
        	
<!--            <br /><br />右边内容区域-->
            
        </div>
        
    </div>
</div>
<script type="text/javascript">
$(document).ready(function(){
    
 $("#file_upload").uploadify({
        height        : 115,
        swf           : '<?php echo image_path('uploadify.swf');?>',
        uploader      : '<?php echo url_for('theme/images');?>',
        width         : 157,
        'buttonText' : '',
        'buttonImage' : '<?php echo image_path('imgAdd.gif'); ?>',
        'method'   : 'post',
        'fileTypeExts' : '*.gif; *.jpg; *.png',
        'queueSizeLimit' : 1,
        'debug' : false,
        onSelect: function(file){
           if($("DIV[upload=images]").length >= 9){
               alert("最多只能上传9张图片哦");
               $('#file_upload').uploadify('cancel', '*');
               return false;
           }
        },
        onUploadSuccess : function(file, data, response) {

            var d = eval('('+data+')');
            var error = d.error;
            var div = $("#imgDiv");
            
            
            if(error == 0){
                var url = d.url;
                var new_div = $("<div></div>").attr('upload','images');
                var img = $("<img />").attr('src',url);
                new_div.append(img);
                div.prepend(new_div);
                var img_input = "<input type='hidden' name='images["+($("DIV[upload=images]").length)+"]' value='"+url+"' />";
                $("#create_theme").append(img_input);
            }else{
                alert("文件上传出错，请重新检查！");
                return false;
            }
            
            return;
        }
    });
});
</script>